home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / gij-wrapper-4.1 < prev    next >
Encoding:
Text File  |  2007-03-03  |  2.7 KB  |  99 lines

  1. #!/usr/bin/perl -w
  2. #
  3. # Starts the GNU Java interpreter.
  4. #
  5. # Command-line arguments should be in the style of Sun's Java runtime;
  6. # these will be converted to gij arguments before being passed to the
  7. # gij itself.
  8. #
  9. # The Debian JNI module directory and any other specified JNI
  10. # directories will be included on the JNI search path.
  11. #
  12. # Copyright (C) 2002-2003 by Ben Burton <bab@debian.org>
  13. # Based on the original gij-wrapper-3.2 shell script.
  14.  
  15. use strict;
  16.  
  17. # The real Java runtime:
  18. my $javaRuntime = '/usr/bin/gij-4.1';
  19.  
  20. # The debian JNI module directory:
  21. my $debianJNIDir = '/usr/lib/jni';
  22.  
  23. # The command-line arguments to pass to the real Java runtime:
  24. my @commandLine;
  25.  
  26. # The full JNI search path to use:
  27. my $JNIPath = '';
  28.  
  29. # Build the command-line from the arguments given.
  30. my $parsingOptions = 1;
  31.  
  32. # Flag used to copy argument to -classpath or -cp.
  33. my $copyNext = 0;
  34. foreach my $arg (@ARGV) {
  35.   if (not $parsingOptions) {
  36.     # We're done parsing options; just copy all remaining arguments directly.
  37.     push @commandLine, $arg;
  38.     next;
  39.   }
  40.   if ($copyNext) {
  41.     push @commandLine, $arg;
  42.     $copyNext = 0;
  43.     next;
  44.   }
  45.  
  46.   # Try to interpret Sun-style options.
  47.   if ($arg eq '-version') {
  48.     push @commandLine, '--version';
  49.   } elsif ($arg eq '-h' or $arg eq '-help') {
  50.     push @commandLine, '--help';
  51.   } elsif ($arg eq '-cp' or $arg eq '--cp') {
  52.     push @commandLine, '-cp';
  53.     $copyNext = 1;
  54.   } elsif ($arg eq '-classpath' or $arg eq '--classpath') {
  55.     push @commandLine, '-classpath';
  56.     $copyNext = 1;
  57.   } elsif ($arg =~ /^-Djava.library.path=(.+)$/) {
  58.     # A component of the JNI search path has been given.
  59.     if ($JNIPath) {
  60.       $JNIPath = $JNIPath . ':' . $1;
  61.     } else {
  62.       $JNIPath = $1;
  63.     }
  64.   } elsif ($arg eq '-jar' or $arg =~ /^-D/) {
  65.     # Copy the argument directly.
  66.     push @commandLine, $arg;
  67.   } elsif ($arg =~ /^-/) {
  68.     # An unrecognised option has been passed - just drop it.
  69.   } else {
  70.     # Some non-option argument has been given.
  71.     # Stop parsing options at this point.
  72.     push @commandLine, $arg;
  73.     $parsingOptions = 0;
  74.   }
  75. }
  76.  
  77. # Add the debian JNI module directory to the JNI search path if it's not
  78. # already there.
  79. if ($JNIPath !~ /(^|:)$debianJNIDir($|:)/) {
  80.   if ($JNIPath) {
  81.     $JNIPath = $JNIPath . ':' . $debianJNIDir;
  82.   } else {
  83.     $JNIPath = $debianJNIDir;
  84.   }
  85. }
  86.  
  87. # Use environment variable $LTDL_LIBRARY_PATH to store the JNI path,
  88. # since gij uses libltdl to dlopen JNI modules.
  89. if ($ENV{LTDL_LIBRARY_PATH}) {
  90.     $ENV{LTDL_LIBRARY_PATH} = $ENV{LTDL_LIBRARY_PATH} . ':' . $JNIPath;
  91. } else {
  92.     $ENV{LTDL_LIBRARY_PATH} = $JNIPath;
  93. }
  94.  
  95. # Call the real Java runtime.
  96. my @fullCommandLine = ( $javaRuntime );
  97. push @fullCommandLine, @commandLine;
  98. exec @fullCommandLine or exit(1);
  99.